package com.zdy.boot.upload.core.job.handler;

import com.zdy.boot.upload.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public abstract class AbstractJobHandler implements JobHandler{

    @Value("${seal.startHour}")
    private String startHour;
    @Value("${seal.endHour}")
    private String endHour;

    @Override
    public String execute(String param) {
        try {
            if (DateUtils.isRange(startHour, endHour)) {
                executeJob(param);
            } else {
                log.warn("当前时间小于开始时间,或晚于结束时间，暂停上传");
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
        return "success";
    }

    public abstract void executeJob(String param);
}
